#!/usr/bin/make -f

#export DH_VERBOSE = 1

RENAME := $(shell sh -c 'command -v rename.ul || command -v rename')
INSTALL := $(shell sh -c 'command -v install')

ifeq (,$(RENAME))
$(error Command not found: rename)
endif
ifeq (,$(INSTALL))
$(error Command not found: install)
endif

%:
	-$(RENAME) PACKAGE #PACKAGE# $(CURDIR)/debian/*
ifdef DO_RELEASE
	sed -i "s/UNRELEASED/$(shell lsb_release -c -s)/" $(CURDIR)/debian/changelog
endif
	dh $@#DH_ADDON#

ifdef PACKAGE
override_dh_gencontrol:
	dh_gencontrol -- -VReplaces=enroot
else
override_dh_gencontrol:
	dh_gencontrol -- -VReplaces=""
endif

override_dh_auto_build:
	dh_auto_build -- prefix= exec_prefix=/usr datarootdir=/usr/share INSTALL="$(INSTALL) --strip-program=true" # XXX: debhelper compat 11

override_dh_auto_install:
	dh_auto_install -- prefix= exec_prefix=/usr datarootdir=/usr/share
	mkdir -p debian/tmp/etc/apparmor.d && mv debian/tmp/usr/share/enroot/apparmor.profile debian/tmp/etc/apparmor.d/enroot

override_dh_shlibdeps:
	dh_shlibdeps -- -l/usr/$(DEB_HOST_MULTIARCH)/lib

override_dh_install:
	dh_movefiles -p #PACKAGE# '*'
	dh_apparmor -p #PACKAGE# --profile-name=enroot
